package com.scf.contract.service.impl;

import com.scf.contract.entity.Borrowing;
import com.scf.contract.entity.Contract;
import com.scf.contract.mapper.BorrowingMapper;
import com.scf.contract.service.BorrowingService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author author
 * @create 2021-11-12-15:08
 */
@Service
public class BorrowingServiceImpl implements BorrowingService {
    @Resource
    BorrowingMapper borrowingMapper;

    @Resource
    RedisTemplate<String, Object> redisTemplate;

    @Override
    @Cacheable(value = "allborrowing")
    public List<Borrowing> selectAll(Integer pageIndex, Integer pageSize) {
        return borrowingMapper.selectAll(pageIndex, pageSize);
    }

    @Override
    @Cacheable(value = "findByName")
    public List<Borrowing> selectByname(String enterprisename, String code) {
        return borrowingMapper.selectByname(enterprisename, code);
    }

    @Override
    public Integer selectCount() {
        return borrowingMapper.selectCount();
    }

    @Override
    public Contract getBorrowingByBoid(int boid) {
        Contract contractByBwid = borrowingMapper.getBorrowingByBoid(boid);
        return contractByBwid;
    }
}
